100 REM **********************************************************************
110 REM FILE NAME     MESSAGE.BAS        ELECTRONIC MESSAGE BOARD/NOTE PAD
120 REM LAST UPDATE   4/21/00
130 REM ---------------------------------------------------------------------
200 KEY OFF:FOR A%=1 TO 10:KEY A%,"":NEXT A%
210 DIM MTYPE$(100),MDATE$(100),MTIME$(100),MMON$(100),MDAY$(100),MDOW$(100),MMSG$(100)
300 DIM TYSTR$(7):DIM TXSTR$(7)
310 TYSTR$(0)="Inactive   ":TXSTR$(0)="            "
320 TYSTR$(1)="Once       ":TXSTR$(1)="DATE/TIME   "
330 TYSTR$(2)="Yearly     ":TXSTR$(2)="TIME/MON/DAY"
340 TYSTR$(3)="Monthly    ":TXSTR$(3)="TIME/DAY    "
350 TYSTR$(4)="Daily      ":TXSTR$(4)="TIME        "
360 TYSTR$(5)="Day of Week":TXSTR$(5)="TIME/DOW    "
370 TYSTR$(6)="Weekday    ":TXSTR$(6)="TIME        "
380 TYSTR$(7)="Weekend Day":TXSTR$(7)="TIME        "
390 DIM DASTR$(7)
400 DASTR$(0)="         ":DASTR$(1)="Monday   ":DASTR$(2)="Tuesday  "
410 DASTR$(3)="Wednesday":DASTR$(4)="Thursday ":DASTR$(5)="Friday   "
420 DASTR$(6)="Saturday ":DASTR$(7)="Sunday   "
430 CLS
490 REM ----- READ MESSAGE FILE AND PUT INTO ARRAY ---
500 CLS
510 ON ERROR GOTO 700
520 OPEN "MESSAGE.TXT" FOR INPUT AS 1
530 NUMMSG=0
540 FOR MSGNUM=1 TO 98
550  IF EOF(1) THEN 650
560  INPUT #1,MTYPE$(MSGNUM)
570  INPUT #1,MDATE$(MSGNUM)
580  INPUT #1,MTIME$(MSGNUM)
590  INPUT #1,MMON$(MSGNUM)
600  INPUT #1,MDAY$(MSGNUM)
610  INPUT #1,MDOW$(MSGNUM)
620  INPUT #1,MMSG$(MSGNUM)
630  NUMMSG=NUMMSG+1
640 NEXT MSGNUM
650 CLOSE #1
660 ON ERROR GOTO 0
670 GOTO 800
680 REM ---
700 RESUME 710
710 ON ERROR GOTO 0
720 GOSUB 4500:REM CREATE MESSAGE FILE
790 REM ---------- INITIALIZATION ----------
800 CLS
810 MSG$="HOME key = Set Alarms/Edit messages,  END key = quit program"
820 ROW=25:GOSUB 9500
990 REM ------------------------- MAIN ALARM LOOP -------------------------
1000 GOSUB 6000:REM ASSIGN DATE AND TIME VARIABLES
1010 MSG$="Alarm/Message System V1.2    "+TIME$+"  "+DASTR$(DOW)+" "+DATE$
1020 ROW=1:GOSUB 9500:PRINT:PRINT
1030 IF RIGHT$(TIME$,2)="01" AND SOUNDFLAG THEN SOUND 880,10
1040 IF RIGHT$(TIME$,2)="02" AND SOUNDFLAG THEN SOUND 880,10
1050 IF RIGHT$(TIME$,2)="03" AND SOUNDFLAG THEN SOUND 880,10:SOUNDFLAG=0
1090 REM ----- SEE IF TIME FOR A MESSAGE -----
1100 FOR MSGNUM=1 TO NUMMSG
1110   IF MTYPE$(MSGNUM)="0" THEN 1370
1120   IF MDATE$(MSGNUM)=DATE$ THEN DATEMAT=-1 ELSE DATEMAT=0
1130   IF MTIME$(MSGNUM)+":00"=TIME$ THEN TIMEMAT=-1 ELSE TIMEMAT=0
1140   IF VAL(MMON$(MSGNUM))=MONTH THEN MONMAT=-1 ELSE MONMAT=0
1150   IF VAL(MDAY$(MSGNUM))=DAY THEN DAYMAT=-1 ELSE DAYMAT=0
1160   IF VAL(MDOW$(MSGNUM))=DOW THEN DOWMAT=-1 ELSE DOWMAT=0
1170   IF MTYPE$(MSGNUM)="1" AND DATEMAT AND TIMEMAT THEN GOSUB 1900
1180   IF MTYPE$(MSGNUM)="2" AND MONMAT AND DAYMAT AND TIMEMAT THEN GOSUB 1900
1190   IF MTYPE$(MSGNUM)="3" AND DAYMAT AND TIMEMAT THEN GOSUB 1900
1200   IF MTYPE$(MSGNUM)="4" AND TIMEMAT THEN GOSUB 1900
1210   IF MTYPE$(MSGNUM)="5" AND DOWMAT AND TIMEMAT THEN GOSUB 1900
1220   IF MTYPE$(MSGNUM)="6" AND (DOW=1 OR DOW=2 OR DOW=3 OR DOW=4 OR DOW=5) AND TIMEMAT THEN GOSUB 1900
1230   IF MTYPE$(MSGNUM)="7" AND (DOW=6 OR DOW=7) AND TIMEMAT THEN GOSUB 1900
1300     REM FOR DEBUGGING
1310     REM PRINT "T=";MTYPE$(MSGNUM);" ";
1320     REM PRINT "D=";MDATE$(MSGNUM);"DM=";DATEMAT;" ";
1330     REM PRINT "T=";MTIME$(MSGNUM);"TM=";TIMEMAT;" ";
1340     REM PRINT "M=";MMON$(MSGNUM);"MM=";MONMAT;" ";
1350     REM PRINT "D=";MDAY$(MSGNUM);"DM=";DAYMAT;" ";
1360     REM PRINT "DOW=";MDOW$(MSGNUM);"DOWM=";DOWMAT
1370 NEXT MSGNUM
1490 REM ----- CHECK FOR KEYS -----
1500 IN$=INKEY$:IF IN$="" THEN 1800
1510 IF IN$<>CHR$(0)+CHR$(79) THEN 1600
1520 CLS:MSG$="End program? (Y or N)":ROW=12:GOSUB 9500
1530 T=TIMER
1540 IF TIMER>T+5 THEN 800
1550 IN$=INKEY$:IF IN$="" THEN 1540
1560 IF IN$="y" OR IN$="Y" THEN CLS:END
1570 IF IN$="n" OR IN$="N" THEN 800
1580 GOTO 1540
1590 REM -----
1600 IF IN$<>CHR$(0)+CHR$(71) THEN 1700
1610 REM -----
1620 CLS:MSG$="Set alarms/edit messages? (Y or N)":ROW=12:GOSUB 9500
1630 T=TIMER
1640 IF TIMER>T+5 THEN 800
1650 IN$=INKEY$:IF IN$="" THEN 1640
1660 IF IN$="y" OR IN$="Y" THEN GOSUB 2000:GOTO 800
1670 IF IN$="n" OR IN$="N" THEN 800
1680 GOTO 1640
1690 REM ----- ERASE MESAGE -----
1700 KEYVAL=ASC(IN$)
1710 IF KEYVAL>=1 AND KEYVAL<=20 THEN LOCATE KEYVAL+2,1:PRINT SPACE$(78);
1790 REM ----- WAIT FOR SECONDS TO CHANGE -----
1800 IN$=INKEY$:IF IN$<>"" THEN 1800
1810 TT$=TIME$
1820 IF TIME$=TT$ THEN 1820
1830 GOTO 1000
1890 REM ----- DISPLAY MESSAGE AND SOUND ALARM -----
1900 DROW=DROW+1:IF DROW>20 THEN DROW=1
1910 LOCATE DROW+2,15
1920 COLOR 15,0:PRINT "^";CHR$(DROW+64);".  ";MMSG$(MSGNUM);:COLOR 7,0
1930 SOUNDFLAG=-1
1940 MSG$="Acknowledge Alarm/Erase message with Ctrl Key associated with message"
1950 ROW=24:GOSUB 9500
1960 RETURN
1990 REM ------------------------- EDIT MESSAGES -------------------------
2000 CLS
2010 MSG$="Editing messages":ROW=1:GOSUB 9500
2020 SMSG=1
2090 REM ---
2100 EMSG=SMSG+6
2110 FOR MSGNUM=SMSG TO EMSG
2120   MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
2130   LOCATE MROW,1:PRINT RIGHT$(STR$(MSGNUM),LEN(STR$(MSGNUM))-1);" ";
2140   LOCATE MROW,5:PRINT "Type:";
2150   LOCATE MROW+1,5:PRINT "Uses:";
2160   LOCATE MROW,10:IF MTYPE$(MSGNUM)="" THEN PRINT "           "; ELSE PRINT TYSTR$(VAL(MTYPE$(MSGNUM)));
2170   LOCATE MROW+1,10:PRINT TXSTR$(VAL(MTYPE$(MSGNUM)));
2180   LOCATE MROW,23:PRINT "Date:";
2190   LOCATE MROW,28:IF MDATE$(MSGNUM)="" THEN PRINT "          "; ELSE PRINT MDATE$(MSGNUM);
2200   LOCATE MROW,40:PRINT "Time:";
2210   LOCATE MROW,45:IF MTIME$(MSGNUM)="" THEN PRINT "     "; ELSE PRINT MTIME$(MSGNUM);
2220   LOCATE MROW,52:PRINT "Mon:";
2230   LOCATE MROW,56:IF MMON$(MSGNUM)="" THEN PRINT "  "; ELSE PRINT MMON$(MSGNUM);
2240   LOCATE MROW,60:PRINT "Day:";
2250   LOCATE MROW,64:IF MDAY$(MSGNUM)="" THEN PRINT "  "; ELSE PRINT MDAY$(MSGNUM);
2260   LOCATE MROW,68:PRINT "DOW:";
2270   LOCATE MROW,72:PRINT DASTR$(VAL(MDOW$(MSGNUM)));
2280   LOCATE MROW+1,23:PRINT "Msg:";
2290   LOCATE MROW+1,28:IF MMSG$(MSGNUM)="" THEN PRINT STRING$(50," "); ELSE PRINT MMSG$(MSGNUM);
2300 NEXT MSGNUM
2390 REM ---
2400 LOCATE 25,10
2410 PRINT "Enter message number to edit, U=up 7, D=down 7, Escape=exit:";
2420 ROW=25:COL=71:LNG=2:TEMP$=""
2430 GOSUB 10000
2440 IF EXIT$="ESC" THEN RETURN
2460 MSGNUM=VAL(TEMP$):IF MSGNUM>=SMSG AND MSGNUM<=EMSG THEN 2700
2470 IF TEMP$="U" OR TEMP$="u" THEN SMSG=SMSG-7
2480 IF TEMP$="D" OR TEMP$="d" THEN SMSG=SMSG+7
2500 IF SMSG<1 THEN SMSG=1
2510 IF SMSG>92 THEN SMSG=92
2520 GOTO 2100
2690 REM ---
2700 MSG$="         Space Bar=change type, Enter=Accept, Escape=quit         "
2710 ROW=25:GOSUB 9500
2720 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
2730 LOCATE MROW,10:COLOR 15,0:PRINT TYSTR$(VAL(MTYPE$(MSGNUM)));:COLOR 7,0
2740 LOCATE MROW+1,10:PRINT TXSTR$(VAL(MTYPE$(MSGNUM)));
2750 IN$=INKEY$:IF IN$="" THEN 2750
2760 IF IN$<>" " THEN 2810
2770 MTYPE=VAL(MTYPE$(MSGNUM))
2780 MTYPE=MTYPE+1:IF MTYPE>7 THEN MTYPE=0
2790 MTYPE$(MSGNUM)=RIGHT$(STR$(MTYPE),LEN(STR$(MTYPE))-1)
2800 GOTO 2730
2810 IF IN$=CHR$(13) THEN LOCATE MROW,10:PRINT TYSTR$(VAL(MTYPE$(MSGNUM)));:GOTO 2900
2820 IF IN$=CHR$(27) THEN 2100
2830 GOTO 2750
2890 REM ---
2900 MSG$="    Enter date in format MM-DD-YYYY, Enter=Accept, Escape=quit    "
2910 ROW=25:GOSUB 9500
2920 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
2930 ROW=MROW:COL=28:LNG=10:TEMP$=MDATE$(MSGNUM)
2940 GOSUB 10000
2950 IF EXIT$="ESC" THEN 2100
2960 MDATE$(MSGNUM)=TEMP$
2965 IF MDATE$(MSGNUM)="" THEN 3100
2970 IF MID$(MDATE$(MSGNUM),3,1)<>"-" THEN BEEP:GOTO 2930
2980 IF MID$(MDATE$(MSGNUM),6,1)<>"-" THEN BEEP:GOTO 2930
3090 REM ---
3100 MSG$="  Enter time in 24 hour format HH:MM, Enter=Accept, Escape=quit   "
3110 ROW=25:GOSUB 9500
3120 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
3130 ROW=MROW:COL=45:LNG=5:TEMP$=MTIME$(MSGNUM)
3140 GOSUB 10000
3150 IF EXIT$="ESC" THEN 2100
3160 MTIME$(MSGNUM)=TEMP$
3170 IF MTIME$(MSGNUM)="" THEN 3400
3180 IF MID$(MTIME$(MSGNUM),3,1)<>":" THEN BEEP:GOTO 3130
3390 REM ---
3400 MSG$="          Enter month (1-12), Enter=Accept, Escape=quit           "
3410 ROW=25:GOSUB 9500
3420 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
3430 ROW=MROW:COL=56:LNG=2:TEMP$=MMON$(MSGNUM)
3440 GOSUB 10000
3450 IF EXIT$="ESC" THEN 2100
3460 MMON$(MSGNUM)=TEMP$
3470 IF MMON$(MSGNUM)="" THEN 3600
3480 IF VAL(MMON$(MSGNUM))<1 OR VAL(MMON$(MSGNUM))>12 THEN BEEP:GOTO 3430
3590 REM ---
3600 MSG$="           Enter day (1-31), Enter=Accept, Escape=quit            "
3610 ROW=25:GOSUB 9500
3620 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
3630 ROW=MROW:COL=64:LNG=2:TEMP$=MDAY$(MSGNUM)
3640 GOSUB 10000
3650 IF EXIT$="ESC" THEN 2100
3660 MDAY$(MSGNUM)=TEMP$
3670 IF MDAY$(MSGNUM)="" THEN 3700
3680 IF VAL(MDAY$(MSGNUM))<1 OR VAL(MDAY$(MSGNUM))>31 THEN BEEP:GOTO 3630
3690 REM ---
3700 MSG$="     Space Bar=change day of week, Enter=Accept, Escape=quit     "
3710 ROW=25:GOSUB 9500
3720 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
3730 LOCATE MROW,72:COLOR 15,0:PRINT DASTR$(VAL(MDOW$(MSGNUM)));:COLOR 7,0
3740 IN$=INKEY$:IF IN$="" THEN 3740
3750 IF IN$<>" " THEN 3800
3760 MDOW=VAL(MDOW$(MSGNUM))
3770 MDOW=MDOW+1:IF MDOW>7 THEN MDOW=0
3780 MDOW$(MSGNUM)=RIGHT$(STR$(MDOW),LEN(STR$(MDOW))-1)
3790 GOTO 3720
3800 IF IN$=CHR$(13) THEN LOCATE MROW,72:PRINT DASTR$(VAL(MDOW$(MSGNUM)));:GOTO 4000
3810 IF IN$=CHR$(27) THEN 2100
3820 GOTO 3750
3990 REM ---
4000 MSG$="              Edit message, Enter=Accept, Escape=quit             "
4010 ROW=25:GOSUB 9500
4020 MROW=((MSGNUM*3) MOD 21):IF MROW=0 THEN MROW=21
4030 ROW=MROW+1:COL=28:LNG=50:TEMP$=MMSG$(MSGNUM)
4040 GOSUB 10000
4050 IF EXIT$="ESC" THEN 2100
4060 MMSG$(MSGNUM)=TEMP$
4090 REM ---
4100 FOR MSGNUM=98 TO 1 STEP -1
4110 IF MTYPE$(MSGNUM)<>"" THEN 4130
4120 NEXT MSGNUM
4130 NUMMSG=MSGNUM
4140 GOSUB 4800:REM WRITE MESSAGE FILE
4150 GOTO 2100
4490 REM --------------- CREATE MESSAGE FILE IF NONE ---------------
4500 GOSUB 6000:REM ASSIGN DATE AND TIME VARIABLES
4510 MTYPE$(1)="1":MDATE$(1)=DATE$
4520 MTIME$(1)=LEFT$(TIME$,5):MMON$(1)="12":MDAY$(1)="31"
4530 MDOW$(1)=RIGHT$(STR$(DOW),LEN(STR$(DOW))-1)
4540 MMSG$(1)="Sample message  (Not all fields are needed)"
4550 NUMMSG=1
4560 GOSUB 4800:REM WRITE MESSAGE FILE
4570 RETURN
4790 REM --------------- WRITE MESSAGE FILE ---------------
4800 ON ERROR GOTO 5000
4810 OPEN "MESSAGE.TXT" FOR OUTPUT AS 1
4820 FOR MSGNUM=1 TO NUMMSG
4830  PRINT #1,CHR$(34);MTYPE$(MSGNUM);CHR$(34);",";
4840  PRINT #1,CHR$(34);MDATE$(MSGNUM);CHR$(34);",";
4850  PRINT #1,CHR$(34);MTIME$(MSGNUM);CHR$(34);",";
4860  PRINT #1,CHR$(34);MMON$(MSGNUM);CHR$(34);",";
4870  PRINT #1,CHR$(34);MDAY$(MSGNUM);CHR$(34);",";
4880  PRINT #1,CHR$(34);MDOW$(MSGNUM);CHR$(34);",";
4890  PRINT #1,CHR$(34);MMSG$(MSGNUM);CHR$(34)
4900 NEXT MSGNUM
4910 CLOSE #1
4920 ON ERROR GOTO 0
4930 RETURN
4990 REM ----- ERROR WRITING FILE -----
5000 RESUME 5010
5010 ON ERROR GOTO 0
5020 MSG$="Problem writing message file"
5030 ROW=24:GOSUB 9500
5040 T=TIMER
5050 IF TIMER<T+2 THEN 5050
5060 MSG$=SPACE$(70):ROW=23:GOSUB 9500
5070 RETURN
5080 REM --------------- ASSIGN DATE AND TIME VARIABLES ----------------
6000 MONTH=VAL(LEFT$(DATE$,2))
6010 DAY=VAL(MID$(DATE$,4,2))
6020 YEAR=VAL(MID$(DATE$,7,4))
6030 IF (MONTH<3) THEN Y=YEAR-1:M=MONTH+12:D=DAY
6040 IF MONTH>=3 THEN Y=YEAR:M=MONTH:D=DAY
6050 DOW=((13*M+3)\5+D+Y+Y\4-Y\100+Y\400+1) MOD 7
6060 DOW$=RIGHT$(STR$(DOW),1)
6070 HOUR=VAL(LEFT$(TIME$,2))
6080 MIN=VAL(RIGHT$(TIME$,2))
6090 RETURN
9460 REM *********************************************************************
9465 REM ------------------- DISPLAY CENTERED MESSAGE ------------------------
9470 REM
9475 REM This subroutine displays a message at the center of a specified row.
9480 REM
9485 REM enter with - MSG$="message", to display
9490 REM              ROW= row on which to display "message"
9495 REM
9500 COL=41-INT((LEN(MSG$)/2))
9505 LOCATE ROW,COL,0:PRINT MSG$;
9510 RETURN
9515 REM
9930 REM *********************************************************************
9935 REM ---------------- EDIT A FIELD AT ROW AND COLUMN ---------------------
9940 REM
9945 REM This subroutine allows you to edit or enter a string. The editing
9950 REM keys work about the same as BASIC in the screen editing mode.
9955 REM
9960 REM enter with - ROW and COL=row and column at which to edit the string
9965 REM              LNG=maximum length of string allowed
9970 REM              TEMP$="string" to edit
9975 REM exit with -  TEMP$="string" edited or entered
9980 REM              EXIT$=key hit that exited routine, "ENTER" or "ESC"
9985 REM              ESCAPE=-1 (TRUE) if ESCAPE key hit
9990 REM              (for compatibility with old versions)
9995 REM
10000 LOCATE ,,0:INS=0:TEMP$=LEFT$(TEMP$,LNG)
10005 IF LEN(TEMP$)=LNG THEN EDCOL=COL+LEN(TEMP$)-1 ELSE EDCOL=COL+LEN(TEMP$)
10010 LOCATE ROW,COL,0:COLOR 0,7:PRINT TEMP$;
10015 LOCATE ROW,COL+LEN(TEMP$):PRINT SPACE$(LNG-LEN(TEMP$));
10020 L=LEN(TEMP$)
10025 AAAA$=MID$(TEMP$,EDCOL-COL+1,1)
10030 IF INS THEN LOCATE ROW,EDCOL:COLOR 15,0
10035 IF INS THEN PRINT AAAA$;:COLOR 0,7
10040 IF EDCOL=COL+LNG THEN EDCOL=EDCOL-1
10045 LOCATE ROW,EDCOL
10050 LOCATE,,1
10055 IN$=INKEY$:IF IN$="" THEN 10055                        :REM WAIT FOR KEY
10060 IF IN$=CHR$(13) THEN EXIT$="ENTER":ESCAPE=0:GOTO 10325 :REM ENTER
10065 IF IN$=CHR$(27) THEN EXIT$="ESC":ESCAPE=-1:GOTO 10325  :REM ESCAPE
10070 IF IN$=CHR$(8) THEN 10180                              :REM BACKSPACE
10075 IF IN$=CHR$(0)+CHR$(75) THEN 10225                     :REM LEFT ARROW
10080 IF IN$=CHR$(0)+CHR$(77) THEN 10240                     :REM RIGHT ARROW
10085 IF IN$=CHR$(0)+CHR$(79) THEN 10275                     :REM END
10090 IF IN$=CHR$(0)+CHR$(82) THEN 10295                     :REM INSERT
10095 IF IN$=CHR$(0)+CHR$(83) THEN 10305                     :REM DELETE
10100 REM ----- allow only legitimate alphanumeric
10105 IF ASC(IN$)<32 OR ASC(IN$)>126 THEN GOSUB 10400:GOTO 10050
10110 REM ----- good character
10115 L=EDCOL-COL:IF INS THEN 10155
10120 REM ----- add character if at end of string
10125 IF EDCOL=COL+LEN(TEMP$) THEN TEMP$=TEMP$+IN$:EDCOL=EDCOL+1:GOTO 10010
10130 REM ----- add character in middle if not in insert mode
10135 TEMP$=LEFT$(TEMP$,L)+IN$+RIGHT$(TEMP$,LEN(TEMP$)-1-L):EDCOL=EDCOL+1
10140 IF EDCOL=COL+LNG THEN GOSUB 10400   :REM beep if typing over last char.
10145 GOTO 10010
10150 REM ----- in insert mode, check for full field
10155 IF LEN(TEMP$)=LNG THEN GOSUB 10400:GOTO 10010        :REM full field
10160 TEMP$=LEFT$(TEMP$,L)+IN$+RIGHT$(TEMP$,LEN(TEMP$)-L)  :REM not full
10165 EDCOL=EDCOL+1:GOTO 10010
10170 REM ----- BACKSPACE -----
10175 REM ----- error if at leftmost column
10180 IF EDCOL=COL THEN GOSUB 10400:GOTO 10010
10185 REM ----- skip moving cursor left if the field is full
10190 IF LEN(TEMP$)=LNG AND EDCOL=COL+LNG-1 THEN 10215
10195 REM ----- normal backspace (in middle of field)
10200 L=EDCOL-1-COL:TEMP$=LEFT$(TEMP$,L)+RIGHT$(TEMP$,LEN(TEMP$)-1-L)
10205 EDCOL=EDCOL-1:GOTO 10010
10210 REM ----- backspace if at rightmost column
10215 TEMP$=LEFT$(TEMP$,LEN(TEMP$)-1):GOTO 10010
10220 REM ----- LEFT ARROW -----
10225 INS=0:IF EDCOL>COL THEN EDCOL=EDCOL-1:GOTO 10010
10230 GOSUB 10400:GOTO 10010                           :REM error if left col
10235 REM ----- RIGHT ARROW -----
10240 INS=0:IF EDCOL<COL+LNG-1 THEN 10255
10245 GOSUB 10400:GOTO 10010                           :REM error if right col
10250 REM ----- move cursor right if applicable
10255 IF EDCOL<COL+LEN(TEMP$) THEN EDCOL=EDCOL+1:GOTO 10010
10260 REM add "blank" character when cursor is moved to right
10265 TEMP$=TEMP$+CHR$(255):EDCOL=EDCOL+1:GOTO 10010
10270 REM ----- END -----
10275 INS=0:IF LEN(TEMP$)=LNG THEN EDCOL=COL+LEN(TEMP$)-1:GOTO 10010
10280 EDCOL=COL+LEN(TEMP$):GOTO 10010
10285 REM:END:IF EDCOL>COL+LNG THEN EDCOL=COL+LNG:GOTO 10025
10290 REM ----- INSERT -----
10295 IF INS THEN INS=0:GOTO 10010 ELSE INS=-1:GOTO 10010
10300 REM ----- DELETE -----
10305 INS=0:L=EDCOL-COL
10310 IF EDCOL>=COL+LEN(TEMP$) THEN GOSUB 10400:GOTO 10010
10315 TEMP$=LEFT$(TEMP$,L)+RIGHT$(TEMP$,LEN(TEMP$)-L-1):GOTO 10010
10320 REM ----- COMMON EXIT -----
10325 REM remove blanks at end
10330 IF RIGHT$(TEMP$,1)=CHR$(255) THEN TEMP$=LEFT$(TEMP$,LEN(TEMP$)-1):GOTO 10330
10335 REM change blanks in middle to spaces
10340 FOR AAAA%=1 TO LEN(TEMP$)
10345 IF MID$(TEMP$,AAAA%,1)=CHR$(255) THEN MID$(TEMP$,AAAA%,1)=" "
10350 NEXT AAAA%
10355 REM redisplay string
10360 LOCATE ROW,COL,0:COLOR 7,0
10365 PRINT TEMP$+SPACE$(LNG-LEN(TEMP$));
10370 RETURN
10375 REM
10395 REM ----- BEEP IF ERROR -----
10400 BEEP:RETURN
10405 REM
